﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Xml.Linq;
using Npgsql;


namespace br.com.SistemaChamados.QueryManager.Utils
{
    public class Mapped
    {
        public static IDbConnection Connection()
        {
            NpgsqlConnection objConexao = new NpgsqlConnection("Server=localhost;Port=5432;Database=sistemachamados;User Id=postgres;Password=postgres;");
            objConexao.Open();
            return objConexao;
        }

        public static IDbCommand Command(string query, IDbConnection aConnection)
        {
            IDbCommand command = aConnection.CreateCommand();
            command.CommandText = query;
            return command;
        }

        public static IDbDataParameter Parameter(string parameterName, object value)
        {
            return new NpgsqlParameter(parameterName, value);
        }

        public static IDbDataAdapter Adapter(IDbCommand command)
        {
            IDbDataAdapter adap = new NpgsqlDataAdapter();
            adap.SelectCommand = command;
            return adap;
        }
    }
}
